﻿using ActionSystem.Core;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using ActionSystem.Input;
using ActionSystem.Core.ActiveLogic;

namespace ActionSystem.Camera
{
    public class BaseCameraHander : BaseStateActionHandler, IActiveLogicActionHandler
    {
        protected ThirdPersonCameraStateMachine cameraMachine;
        protected UnityEngine.Camera camera;
        protected ICameraInfo info;
        protected ICameraFollowInfo follow;
        protected InputModule input;
        public override void Enter(BaseStateAction action)
        {
            base.Enter(action);
            cameraMachine = action.StateMachine as ThirdPersonCameraStateMachine;
            camera = cameraMachine?.GetCamera();
            info = action.StateMachine as ICameraInfo;
            follow = (cameraMachine as ICameraFollowInfoHolder)?.GetCameraFollow();
            input = cameraMachine.GetInput();
        }
       

        public void PostUpdate(BaseStateAction action, float deltaTime)
        {
            //如果正在过度到下一个就不使用当前的数据
            if (action.StateMachine.CurrentState == action.State && action.StateMachine.NextState != null)
            {
                return;
            }
            SetUpCameraInfo(action,deltaTime);
        }
        public virtual void SetUpCameraInfo(BaseStateAction action, float deltaTime) { }
        public virtual void Update(BaseStateAction action, float deltaTime)
        {

        }
        public override void Exit(BaseStateAction action)
        {
            base.Exit(action);
            cameraMachine = null;
            info = null;
        }
    }

}

